package ch02.graphics;

import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.geom.Ellipse2D;

public class BullsEye 
{
	private int _x;
	private int _y;
	private int _size;
	private int _rings;
	
	public BullsEye(int x, int y, int size, int rings)
	{
		_x = x;
		_y = y;
		_size = size;
		_rings = rings;
	}
	
	public void draw(Graphics2D g2)
	{		
		Ellipse2D.Double ring;
		int ringSize = _size / _rings;
		
		for(int i = _rings; i > 0; i --)
		{			
			if(i % 2 == 0)
			{
				g2.setColor(Color.WHITE);
			}
			else 
			{
				g2.setColor(Color.BLACK);				
			}			
			ring = new Ellipse2D.Double(_x - ringSize * i / 2, _y - ringSize * i / 2, ringSize * i, ringSize * i);		
			g2.fill(ring);			
		}
		
	}

}
